import commanderInstance from "../exports/commanderInstance";
import jmacApi from "../exports/jmacApi";
import telegram from "../exports/telegram";
import * as keyboards from "../modules/keyboards";

commanderInstance.addCommand({
    name: "joke",
    triggers: [/joke/gi],
    handler: async (context) => {
        const result = await jmacApi.commands.text.joke.handler();
        if (context.answerCallbackQuery) {
            return telegram.api.editMessageText({
                chat_id: context.message.chat.id,
                message_id: context.message.id,
                text: result,
                reply_markup: keyboards.updateButton({
                    command: "joke",
                }),
            });
        }
        context.reply(result, {
            reply_markup: keyboards.updateButton({ command: "joke" }),
        });
    },
});
